/*
 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

/*
 * @(#)DBMetaClient6.java	1.16 02/01/12
 */

package jdbcts.dbMeta.dbMeta6;

import java.io.*;
import java.util.*;

import java.sql.*;
import javax.sql.*;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import com.sun.cts.util.*;
import com.sun.cts.porting.*;
import com.sun.cts.harness.*;

import java.rmi.RemoteException;

import javasoft.sqe.javatest.Status;
import jdbcts.SuperTest;
import jdbcts.common.DataSourceConnection;
import jdbcts.common.DriverManagerConnection;
import jdbcts.common.dbSchema;

import com.sun.cts.tests.jdbc.ee.common.*;

// Merant DataSource class
//import com.merant.sequelink.jdbcx.datasource.*;

/**
 * The DBMetaClient6 class tests methods of DatabaseMetaData interface using
 * Sun's J2EE Reference Implementation.
 * 
 * @author
 * @version 1.7, 06/16/99
 */

public class DBMetaClient6 extends SuperTest implements Serializable
{
    private static final String testName = "jdbc.ee.dbMeta.dbMeta6";

    // Naming specific member variables
    private CTSNamingContextInterface jc = null;

    // Harness requirements

    private transient static Connection conn = null;

    private transient static DatabaseMetaData dbmd = null;

    private DataSource ds1 = null;

    private static dbSchema dbSch = null;

    private String dbName = null, dbUser = null;

    static String drManager = null;

    private String sCatalogName = null, sSchemaName = null, sPtable = null,
	    sFtable = null;

    /* Run test in standalone mode */
    // public static void main(String[] args)
    // {
    // DBMetaClient6 theTests = new DBMetaClient6();
    // Status s=theTests.run(args, System.out, System.err);
    // s.exit();
    // }
    /* Test setup: */
    /*
     * @class.setup_props: Driver, the Driver name; db1, the database name with
     * url; user1, the database user name; password1, the database password;
     * db2, the database name with url; user2, the database user name;
     * password2, the database password; DriverManager, flag for DriverManager;
     * ptable, the primary table; ftable, the foreign table; cofSize, the
     * initial size of the ptable; cofTypeSize, the initial size of the ftable;
     * binarySize, size of binary data type; varbinarySize, size of varbinary
     * data type; longvarbinarySize, size of longvarbinary data type;
     * 
     * @class.testArgs: -ap ctssql.stmt
     */
    @BeforeClass
    // public void setup(String[] args, Properties p) throws Exception
    public static void setup() throws Exception
    {
	try
	{
	    try
	    {
//		drManager = p.getProperty("DriverManager", "");
		drManager = isDRManager;
//		dbName = p.getProperty("db1", "");
//		dbUser = p.getProperty("user1", "");
//		sPtable = p.getProperty("ptable", "CTSTABLE1");
//		sFtable = p.getProperty("ftable", "CTSTABLE2");
//		if (dbName.length() == 0)
//		    throw new Exception("Invalid db1  Database Name");
//		if (dbUser.length() == 0)
//		    throw new Exception("Invalid Login Id");
//		if (sPtable.length() == 0)
//		    throw new Exception("Invalid Primary table");
//		if (sFtable.length() == 0)
//		    throw new Exception("Invalid Foreign table");
		if (drManager.length() == 0)
		    throw new Exception("Invalid DriverManager Name");

//		int nLocdbname = dbName.indexOf('=');
//		sCatalogName = dbName.substring(nLocdbname + 1);
//		sCatalogName = sCatalogName.trim();
//		sSchemaName = dbUser;

		if (drManager.equals("yes"))
		{
		    logMsg("Using DriverManager");
		    DriverManagerConnection dmCon = new DriverManagerConnection();
//		    conn = dmCon.getConnection(p);
		    conn = dmCon.getConnection(null);
		}
		else
		{
		    logMsg("Using DataSource");
		    DataSourceConnection dsCon = new DataSourceConnection();
//		    conn = dsCon.getConnection(p);
		    conn = dsCon.getConnection(null);
		}
		dbSch = new dbSchema();
//		dbSch.createData(p, conn);
		dbmd = conn.getMetaData();

	    }
	    catch (SQLException ex)
	    {
		logErr("SQL Exception : " + ex.getMessage());
	    }
	}
	catch (Exception e)
	{
	    logErr("Setup Failed!");
	    TestUtil.printStackTrace(e);
	}
    }

    /*
     * @testName: testGetCatalogSeparator
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getCatalogSeparator()
     * method must return a String value representing the separator string. (See
     * JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase. Make a call to DatabaseMetadata.getCatalogSeparator() on
     * that object. It should return a String and NULL if it is not supported.
     */
    @Test
    public void testGetCatalogSeparator() throws Exception
    {
	try
	{
	    // invoke getCatalogSeparator method
	    logMsg("Calling DatabaseMetaData.getCatalogSeparator");
	    String sRetValue = dbmd.getCatalogSeparator();
	    if (sRetValue == null)
		logMsg("getCatalogSeparator is not supported");
	    else
		logMsg("getCatalogSeparator returns " + sRetValue);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to getCatalogSeparator is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to getCatalogSeparator is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsSchemasInDataManipulation
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsSchemasInDataManipulation() method must return a boolean value;
     * true if the database supports using a schema name in a data manipulation
     * statement and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase. Make a call to
     * DatabaseMetadata.supportsSchemasInDataManipulation() on that object. It
     * should return a boolean value either true or false.
     */
    @Test
    public void testSupportsSchemasInDataManipulation() throws Exception
    {
	try
	{
	    // invoke supportsSchemasInDataManipulation method
	    logMsg("Calling DatabaseMetaData.supportsSchemasInDataManipulation");
	    boolean retValue = dbmd.supportsSchemasInDataManipulation();
	    if (retValue)
		logMsg("supportsSchemasInDataManipulation is supported");
	    else
		logMsg("supportsSchemasInDataManipulation is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsSchemasInDataManipulation is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsSchemasInDataManipulation is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsSchemasInProcedureCalls
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsSchemasInProcedureCalls() method must return a boolean value;
     * true if the database supports using a schema name in a procedure call
     * statement and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase. Make a call to
     * DatabaseMetadata.supportsSchemasInProcedureCalls() on that object. It
     * should return a boolean value; either true or false
     */
    @Test
    public void testSupportsSchemasInProcedureCalls() throws Exception
    {
	try
	{
	    // invoke supportsSchemasInProcedureCalls method
	    logMsg("Calling DatabaseMetaData.supportsSchemasInProcedureCalls");
	    boolean retValue = dbmd.supportsSchemasInProcedureCalls();
	    if (retValue)
		logMsg("supportsSchemasInProcedureCalls is supported");
	    else
		logMsg("supportsSchemasInProcedureCalls is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsSchemasInProcedureCalls is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsSchemasInProcedureCalls is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsSchemasInTableDefinitions
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsSchemasInTableDefinitions() method must return a boolean value;
     * true if the database supports using a schema name in a table definition
     * statement and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase. Make a call to
     * DatabaseMetadata.supportsSchemasInTableDefinitions() on that object.It
     * should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsSchemasInTableDefinitions() throws Exception
    {
	try
	{
	    // invoke supportsSchemasInTableDefinitions method
	    logMsg("Calling DatabaseMetaData.supportsSchemasInTableDefinitions");
	    boolean retValue = dbmd.supportsSchemasInTableDefinitions();
	    if (retValue)
		logMsg("supportsSchemasInTableDefinitions is supported");
	    else
		logMsg("supportsSchemasInTableDefinitions is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsSchemasInTableDefinitions is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsSchemasInTableDefinitions is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsSchemasInIndexDefinitions
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsSchemasInIndexDefinitions() method must return a boolean value;
     * true if the database supports using a schema name in a index definition
     * statement and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase. Call to supportsSchemasInIndexDefinitions() on that object.
     * It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsSchemasInIndexDefinitions() throws Exception
    {
	try
	{
	    // invoke supportsSchemasInIndexDefinitions method
	    logMsg("Calling DatabaseMetaData.supportsSchemasInIndexDefinitions");
	    boolean retValue = dbmd.supportsSchemasInIndexDefinitions();
	    if (retValue)
		logMsg("supportsSchemasInIndexDefinitions is supported");
	    else
		logMsg("supportsSchemasInIndexDefinitions is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsSchemasInIndexDefinitions is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsSchemasInIndexDefinitions is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsSchemasInPrivilegeDefinitions
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsSchemasInPrivilegeDefinitions() method must return a boolean
     * value; true if the database supports using a schema name in a privilege
     * definition statement and false otherwise. (See JDK 1.2.2 API
     * documentation).
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase. Call to supportsSchemasInPrivilegeDefinitions() on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsSchemasInPrivilegeDefinitions() throws Exception
    {
	try
	{
	    // invoke supportsSchemasInPrivilegeDefinitions method
	    logMsg("Calling DatabaseMetaData.supportsSchemasInPrivilegeDefinitions");
	    boolean retValue = dbmd.supportsSchemasInPrivilegeDefinitions();
	    if (retValue)
		logMsg("supportsSchemasInPrivilegeDefinitions is supported");
	    else
		logMsg("supportsSchemasInPrivilegeDefinitions is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsSchemasInPrivilegeDefinitions is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsSchemasInPrivilegeDefinitions is Failed!",
		    e);
	}
    }

    /*
     * @testName: testSupportsCatalogsInDataManipulation
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsCatalogsInDataManipulation() method must return a boolean value;
     * true if the database supports using a catalog name in a data manipulation
     * statement and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase. Call to supportsCatalogsInDataManipulation()on that object.
     * It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsCatalogsInDataManipulation() throws Exception
    {
	try
	{
	    // invoke supportsCatalogsInDataManipulation method
	    logMsg("Calling DatabaseMetaData.supportsCatalogsInDataManipulation");
	    boolean retValue = dbmd.supportsCatalogsInDataManipulation();
	    if (retValue)
		logMsg("supportsCatalogsInDataManipulation is supported");
	    else
		logMsg("supportsCatalogsInDataManipulation is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsCatalogsInDataManipulation is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsCatalogsInDataManipulation is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsCatalogsInProcedureCalls
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsCatalogsInProcedureCalls() method must return a boolean value;
     * true if the database supports using a catalog name in a procedure call
     * statement and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get the DataBaseMetaData object from the Connection to
     * the DataBase. Call to supportsCatalogsInProcedureCalls() on that object.
     * It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsCatalogsInProcedureCalls() throws Exception
    {
	try
	{
	    // invoke supportsCatalogsInProcedureCalls method
	    logMsg("Calling DatabaseMetaData.supportsCatalogsInProcedureCalls");
	    boolean retValue = dbmd.supportsCatalogsInProcedureCalls();
	    if (retValue)
		logMsg("supportsCatalogsInProcedureCalls is supported");
	    else
		logMsg("supportsCatalogsInProcedureCalls is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsCatalogsInProcedureCalls is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsCatalogsInProcedureCalls is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsCatalogsInTableDefinitions
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsCatalogsInTableDefinitions() method must return a boolean value;
     * true if the database supports using a catalog name in a table definition
     * statement and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database Call the supportsCatalogsInTableDefinitions() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsCatalogsInTableDefinitions() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsCatalogsInTableDefinitions()");
	    // Invoke supportsCatalogsInTableDefinitions method
	    boolean retValue = dbmd.supportsCatalogsInTableDefinitions();
	    if (retValue)
		logMsg("supportsCatalogsInTableDefinitions is supported");
	    else
		logMsg("supportsCatalogsInTableDefinitions is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsCatalogsInTableDefinitions is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsCatalogsInTableDefinitions is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsCatalogsInIndexDefinitions
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsCatalogsInIndexDefinitions() method must return a boolean value;
     * true if the database supports using a catalog name in a index definition
     * statement and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database Call the supportsCatalogsInIndexDefinitions() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsCatalogsInIndexDefinitions() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsCatalogsInIndexDefinitions");
	    // invoke supportsCatalogsInIndexDefinitions method
	    boolean retValue = dbmd.supportsCatalogsInIndexDefinitions();
	    if (retValue)
		logMsg("supportsCatalogsInIndexDefinitions is supported");
	    else
		logMsg("supportsCatalogsInIndexDefinitions is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsCatalogsInIndexDefinitions is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsCatalogsInIndexDefinitions is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsCatalogsInPrivilegeDefinitions
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsCatalogsInPrivilegeDefinitions() method must return a boolean
     * value; true if the database supports using a catalog name in a privilege
     * definition statement and false otherwise. (See JDK 1.2.2 API
     * documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the supportsCatalogsInPrivilegeDefinitions() method on
     * that object. It should return a boolean value; either true or false
     */
    @Test
    public void testSupportsCatalogsInPrivilegeDefinitions() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsCatalogsInPrivilegeDefinitions");
	    // invoke supportsCatalogsInPrivilegeDefinitions method
	    boolean retValue = dbmd.supportsCatalogsInPrivilegeDefinitions();
	    if (retValue)
		logMsg("supportsCatalogsInPrivilegeDefinitions is supported");
	    else
		logMsg("supportsCatalogsInPrivilegeDefinitions is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsCatalogInPrivilegeDefinitions is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsCatalogsInPrivilegeDefinitions is Failed!",
		    e);
	}
    }

    /*
     * @testName: testSupportsPositionedDelete
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsPositionedDelete() method must return a boolean value; true if
     * the database supports positioned DELETE statement and false
     * otherwise.(See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the supportsPositionedDelete() method on that object.
     * It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsPositionedDelete() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsPositionedDelete");
	    // invoke supportsPositionedDelete method
	    boolean retValue = dbmd.supportsPositionedDelete();
	    if (retValue)
		logMsg("supportsPositionedDelete is supported");
	    else
		logMsg("supportsPositionedDelete is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsPositionedDelete is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsPositionedDelete is Failed!",
		    e);
	}
    }

    /*
     * @testName: testSupportsPositionedUpdate
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsPositionedUpdate() method must return a boolean value; true if
     * the database supports positioned UPDATE statement and false
     * otherwise.(See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the supportsPositionedUpdate() method on that object.
     * It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsPositionedUpdate() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsPositionedUpdate");
	    // invoke supportsPositionedUpdate method
	    boolean retValue = dbmd.supportsPositionedUpdate();
	    if (retValue)
		logMsg("supportsPositionedUpdate is supported");
	    else
		logMsg("supportsPositionedUpdate is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsPositionedUpdate is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsPositionedUpdate is Failed!",
		    e);
	}
    }

    /*
     * @testName: testSupportsSelectForUpdate
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsSelectForUpdate() method must return a boolean value; true if the
     * database supports positioned UPDATE statement and false otherwise.(See
     * JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the supportsSelectForUpdate() method on that object. It
     * should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsSelectForUpdate() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsSelectForUpdate");
	    // invoke supportsSelectForUpdate method
	    boolean retValue = dbmd.supportsSelectForUpdate();
	    if (retValue)
		logMsg("supportsSelectForUpdate is supported");
	    else
		logMsg("supportsSelectForUpdate is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsSelectForUpdate is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsSelectForUpdate is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsSubqueriesInComparisons
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsSubqueriesInComparisons() method must return a boolean value;
     * true if the database supports subqueries in comparison expressions and
     * false otherwise. A JDBC compliant driver always returns true. (See JDK
     * 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the supportsSubqueriesInComparisons() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsSubqueriesInComparisons() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsSubqueriesInComparisons");
	    // invoke supportsSubqueriesInComparisons method
	    boolean retValue = dbmd.supportsSubqueriesInComparisons();
	    if (retValue)
		logMsg("supportsSubqueriesInComparisons is supported");
	    else
		logMsg("supportsSubqueriesInComparisons is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsSubqueriesInComparisons is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsSubqueriesInComparisons is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsSubqueriesInExists
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsSubqueriesInExists() method must return a boolean value; true if
     * the database supports subqueries in EXISTS expressions and false
     * otherwise. A JDBC compliant driver always returns true. (See JDK 1.2.2
     * API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the supportsSubqueriesInExists() method on that object.
     * It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsSubqueriesInExists() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsSubqueriesInExists");
	    // invoke supportsSubqueriesInExists method
	    boolean retValue = dbmd.supportsSubqueriesInExists();
	    if (retValue)
		logMsg("supportsSubqueriesInExists is supported");
	    else
		logMsg("supportsSubqueriesInExists is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsSubqueriesInExists is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsSubqueriesInExists is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsSubqueriesInIns
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsSubqueriesInIns() method must return a boolean value; true if the
     * database supports subqueries in "IN" statements and false otherwise. A
     * JDBC Compliant driver always returns true. (See JDK 1.2.2 API
     * documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the supportsSubqueriesInIns() method on that object. It
     * should return a boolean value either true or false.
     */
    @Test
    public void testSupportsSubqueriesInIns() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsSubqueriesInIns");
	    // invoke supportsSubqueriesInIns method
	    boolean retValue = dbmd.supportsSubqueriesInIns();
	    if (retValue)
		logMsg("supportsSubqueriesInIns is supported");
	    else
		logMsg("supportsSubqueriesInIns is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsSubqueriesInIns is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsSubqueriesInIns is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsSubqueriesInQuantifieds
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsSubqueriesInQuantifieds() method must return a boolean value;
     * true if the database supports subqueries in quantified statement and
     * false otherwise. A JDBC Compliant driver always returns true. (See JDK
     * 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the supportsSubqueriesInQuantifieds() method on that
     * object. It should return a boolean value either true or false.
     */
    @Test
    public void testSupportsSubqueriesInQuantifieds() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsSubqueriesInQuantifieds");
	    // invoke supportsSubqueriesInQuantifieds method
	    boolean retValue = dbmd.supportsSubqueriesInQuantifieds();
	    if (retValue)
		logMsg("supportsSubqueriesInQuantifieds is supported");
	    else
		logMsg("supportsSubqueriesInQuantifieds is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsSubqueriesInQuantifieds is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsSubqueriesInQuantifieds Failed!", e);
	}
    }

    /*
     * @testName: testSupportsCorrelatedSubqueries
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsCorrelatedSubqueries() method must return a boolean value; true
     * if the database supports correlated subqueries and false otherwise. A
     * JDBC Compliant driver always returns true. (See JDK 1.2.2 API
     * documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the supportsCorrelatedSubqueries() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsCorrelatedSubqueries() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsCorrelatedSubqueries");
	    // invoke supportsCorrelatedSubqueries method
	    boolean retValue = dbmd.supportsCorrelatedSubqueries();
	    if (retValue)
		logMsg("supportsCorrelatedSubqueries is supported");
	    else
		logMsg("supportsCorrelatedSubqueries is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsCorrelatedSubqueries is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsCorrelatedSubqueries is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsUnion
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The supportsUnion() method
     * must return a boolean value; true if the database supports SQL Union and
     * false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the supportsUnion() method on that object. It should
     * return a boolean value; either true or false.
     */
    @Test
    public void testSupportsUnion() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsUnion");
	    // invoke supportsUnion method
	    boolean retValue = dbmd.supportsUnion();
	    if (retValue)
		logMsg("supportsUnion is supported");
	    else
		logMsg("supportsUnion is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsUnion is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected exception " + e.getMessage());
	    throw new Exception("Call to supportsUnion is Failed!", e);
	}
    }

    /* cleanup */
    @AfterClass
    public static void cleanup() throws Exception
    {
	try
	{
	    // Close the database
//	    dbSch.destroyData(conn);
	    dbSch.dbUnConnect(conn);
	    logMsg("Cleanup ok;");
	}
	catch (Exception e)
	{
	    logErr("An error occurred while closing the database connection");
	}
    }
}
